@extends('layouts.admin')
@section('css')
    <style>
        .visible-lg{
            display: inline-block !important;
        }
    </style>
    <link href="{{ asset('static/toastr/toastr.css') }}" rel="stylesheet" type="text/css" />
@stop
@section('content')
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
        <div class="row">
            <div class="col-md-5">
                <h1 class="page-header">添加</h1>
                <form action="{{url("admin/category/store")}}" method="post" autocomplete="off">
                    {{ csrf_field() }}
                    <div class="form-group">
                        <label for="category-name">分类名称</label>
                        <input type="text" name="name" value="{{old('name')}}" class="form-control" placeholder="在此处输入分类名称" autocomplete="off">
                        <span class="prompt-text">这将是它在站点上显示的名字。</span> </div>
                    <div class="form-group">
                        <label for="category-alias">关键词</label>
                        <input type="text" name="keywords" value="{{old('keywords')}}" class="form-control" placeholder="在此处输入分类别名" autocomplete="off">
                        <span class="prompt-text">分类的关键词信息</span> </div>
                    <div class="form-group">
                        <label for="category-alias">排序值</label>
                        <input type="number" name="sort" value="{{old('sort')}}" class="form-control" placeholder="在此处输入排序值" autocomplete="off">
                        <span class="prompt-text">排序越大越靠前</span> </div>
                    <div class="form-group">
                        <label for="category-fname">父级分类</label>
                        <select id="category-fname" class="form-control" name="pid">
                            <option value="0" selected>无</option>
                            @foreach($cats as $v)
                            <option value="{{$v->id}}">{{$v->name}}</option>
                            @endforeach
                        </select>
                        <span class="prompt-text">分类是有层级关系的，您可以有一个“音乐”分类目录，在这个目录下可以有叫做“流行”和“古典”的子目录。</span> </div>
                    {{--<div class="form-group">--}}
                        {{--<label for="category-keywords">关键字</label>--}}
                        {{--<input type="text" id="category-keywords" name="keywords" class="form-control" placeholder="在此处输入分类关键字" autocomplete="off">--}}
                        {{--<span class="prompt-text">关键字会出现在网页的keywords属性中。</span> </div>--}}
                    <div class="form-group">
                        <label for="category-describe">描述</label>
                        <textarea class="form-control" name="description" value="{{old('description')}}" rows="4" autocomplete="off"></textarea>
                        <span class="prompt-text">描述会出现在网页的description属性中。</span> </div>
                    <button class="btn btn-primary" type="submit">添加新分类</button>
                </form>
            </div>
            <div class="col-md-7">
                <h1 class="page-header">管理 <span class="badge">{{count($categorys)}}</span></h1>
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th><span class="glyphicon glyphicon-paperclip"></span> <span class="visible-lg">ID</span></th>
                            <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">名称</span></th>
                            <th><span class="glyphicon glyphicon-list-alt"></span> <span class="visible-lg">关键词</span></th>
                            <th><span class="glyphicon glyphicon-pushpin"></span> <span class="visible-lg">排序</span></th>
                            <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
                        </tr>
                        </thead>
                        <tbody>
                        @if($categorys)
                            @foreach($categorys as $v)
                        <tr>
                            <td>{{$v->id}}</td>
                            <td>{{$v->name}}</td>
                            <td>{{$v->keywords}}</td>
                            <td>{{$v->sort}}</td>
                            <td><a href="{{url("admin/category/edit",$v->id)}}">修改</a> <a href="{{url("admin/category/destroy",$v->id)}}"  rel="1">删除</a></td>
                        </tr>
                        @endforeach
                        @endif
                        </tbody>
                    </table>
                    <span class="prompt-text"><strong>注：</strong>删除一个分类也会删除分类下的文章和子分类,请谨慎删除!</span> </div>
            </div>
        </div>
    </div>

    @section('js')
        <script src="{{ asset('static/toastr/toastr.js') }}"></script>
        <script>
        //错误提示
        @if ($errors->any())
            @foreach ($errors->all() as $error)
                toastr.error("{{$error}}")
            @endforeach
        @endif
        </script>
    @stop
@stop